package org.qiandaosystem.qiandaosystemsource.mapper;

import org.apache.ibatis.annotations.*;
import org.qiandaosystem.qiandaosystemsource.entity.User;

@Mapper
public interface UserMapper {
    
    @Select("SELECT * FROM users WHERE username = #{username}")
    User findByUsername(String username);
    
    @Select("SELECT * FROM users WHERE id = #{id}")
    User findById(Integer id);
    
    @Insert("INSERT INTO users(username, password, role, created_at) VALUES(#{username}, #{password}, #{role}, #{createdAt})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(User user);
    
    @Update("UPDATE users SET password = #{password}, role = #{role} WHERE id = #{id}")
    int update(User user);
    
    @Delete("DELETE FROM users WHERE id = #{id}")
    int deleteById(Integer id);
} 